<%@ page pageEncoding="UTF-8" %>

<div style="width: 360px; margin-top: 20px; text-align: center">
    <table style="width: 320px; height: 200px;">
        <tr>
            <td style="width: 100px">公司id：</td>
            <td><input id="gsid" type="text" /></td>
        </tr>
        <tr>
            <td>凭证密码：</td>
            <td><input id="credential" type="password" /></td>
        </tr>
    </table>

    <button id="save" onclick="save()" style="width: 60px; height: 30px; margin-top: 20px;">保存</button>
</div>

<script>
    $("table td:nth-child(1)").css("text-align", "right");
    show();

    // 展示
    function show() {
        const result = ajaxMethod("showCredential");

        if (result.code == 0) {
            $("#gsid").val(result.data.gsid);
            $("#credential").val(result.data.credential);
        }
    }

    // 保存
    function save() {
        let param = {};
        param["gsid"] = $("#gsid").val();
        param["credential"] = $("#credential").val();

        const result = ajaxMethod("saveCredential", param);

        if (result.code == 0) {
            alert("保存成功");
        } else {
            alert("失败");
        }
    }
</script>
